import { BasePlugin } from "./BasePlugin";
import { Main } from "../Main";

export class Help extends BasePlugin {
    do(args: string[], cb:()=>void): void {
        console.log("帮助");
        if (args[0]) {
            // 显示一个命令的帮助
            let pluginKey = args[0];
            let plugin = Main.plugins[pluginKey];
            console.log("命令:" + pluginKey
                + "\n" + "名称:" + plugin.getName()
                + "\n" + "描述:" + plugin.getDesc()
            );
        } else {
            // 显示所有命令
            for (const key in Main.plugins) {
                if (Main.plugins.hasOwnProperty(key)) {
                    const plugin = Main.plugins[key];
                    console.log("命令:" + key + "\t" + plugin.getName() + "\t" + "描述:" + plugin.getDesc());
                }
            }
        }
        cb();
    }
    getName(): string {
        return "帮助"
    }
    getDesc(): string {
        return "help 要查看帮助的命令\n如果不填要帮助的命令，则列出所有命令和简介"
    }

}